<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<base href="${pageContext.request.contextPath }/">
<title>CPI大数据编辑</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" href="css/pagestyle.css" type="text/css">
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
	function datachild() {
		if ($("#datatype").val() == "") {
			$("#datatypechild").html("<option value=''>请选择</option>");
		} else {
			$.ajax({
				type : "get",
				url : "DataTypeServlet?parentid=" + $("#datatype").val(),
				async : true,
				dataType : "json",
				success : cpidatatype,
				error : errorinfo
			});
		}
	}
	function cpidatatype(data) {
		var str = "<option value=''>请选择</option>";
		$(data).each(
			function(i) {
				if (data[i].datatypeid == "${datatypechildval}")
					str += "<option value='"+data[i].datatypeid+"' selected='selected'>"
							+ data[i].datatypename + "</option>";
				else
					str += "<option value='"+data[i].datatypeid+"'>"
							+ data[i].datatypename + "</option>";
			});
		$("#datatypechild").html(str);
	}
	function errorinfo() {
		alert("请求服务器失败");
	}
	$(function() {
		datachild();
	});
</script>
</head>
<body>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td width="153" height="48"><img src="images/projectmanager.gif"
				width="153" height="48"></td>
			<td background="images/maintitle-bg.gif">&nbsp;</td>
			<td width="80"><img src="images/maintitle-right.gif" width="80"
				height="48"></td>
		</tr>
	</table>
	<table width="100%" border="0" cellpadding="0" cellspacing="0"
		class="pagenav">
		<tr>
			<td width="700" height="22">
				<form action="CpiDataListServlet" method="post">
					<table width="600" border="0" cellpadding="0" cellspacing="5">
						<tr>
							<td nowrap><strong>搜索条件：</strong>CPI数据类别 <select
								id="datatype" name="datatype" onchange="datachild()">
									<option value="">请选择</option>
									<c:forEach items="${datatype}" var="item">
										<c:choose>
											<c:when test="${datatypeval eq item.datatypeid}">
												<option value="${item.datatypeid}" selected="selected">${item.datatypename}</option>
											</c:when>
											<c:otherwise>
												<option value="${item.datatypeid}">${item.datatypename}</option>
											</c:otherwise>
										</c:choose>
									</c:forEach>
							</select> CPI数据子类 <select id="datatypechild" name="datatypechild">
									<option value="">请选择</option>
							</select> &nbsp;&nbsp;数据来源区域 <select id="dataarea" name="dataarea">
									<option value="">请选择</option>
									<c:forEach items="${areatype}" var="item">
										<c:choose>
											<c:when test="${item.areaid eq dataareaval }">
												<option value="${item.areaid}" selected="selected">${item.areaname}</option>
											</c:when>
											<c:otherwise>
												<option value="${item.areaid}">${item.areaname}</option>
											</c:otherwise>
										</c:choose>
									</c:forEach>
							</select>&nbsp;&nbsp;时间 <input type="date" id="cpidate" name="cpidate"
								value="${cpidateval }"></td>
							<td><input id="btnsubmit" name="btnsubmit" type="image"
								src="images/bseach.gif"></td>
						</tr>
					</table>
				</form>
			</td>
			<td align="right"><a href="getParentDataServlet"><img
					src="images/add.gif" align="absmiddle" border="0">添加新数据</a></td>
		</tr>
	</table>
	<div id="bottomdiv" align="center">
		<table id="data" width="100%" border="0" cellpadding="0"
			cellspacing="1" bgcolor="#ADC7D8" class="maincontentbluebg">
			<tr>
				<th height="24" align="center" class="maintitle">序号</th>
				<th align="center" class="maintitle">CPI类别</th>
				<th align="center" class="maintitle">数据来源区域</th>
				<th align="center" class="maintitle">价格</th>
				<th align="center" class="maintitle">数据时间</th>
				<th align="center" class="maintitle">编辑</th>
				<th align="center" class="maintitle">删除</th>
			</tr>

			<c:forEach items="${cpidataarea}" var="item" varStatus="itemstatus">

				<tr bgcolor="#FFFFFF" height="23">
					<td align="center">${(mypage.pageIndex-1)*mypage.pageSize+itemstatus.count}</td>
					<td align="center">${item.dt.datatypename }</td>
					<td align="center">${item.at.areaname}</td>
					<td align="center">￥${item.cd.cpidata}/${item.cd.databit}</td>
					<td align="center">${item.cd.ontime}</td>
					<td align="center"><a href="CPIEditServlet?id=${item.cd.id }"><img
							src="images/edit.gif" border="0"></a></td>
					<td align="center"><a
						href="DelCPIDataController?id=${item.cd.id }"
						onclick='return confirm("确定要删除此数据吗？");'><img
							src="images/delimg.gif" border="0"></a></td>
				</tr>

			</c:forEach>




		</table>
		<div class="pagenav" style="width: 50%; height; 25 px; float: right;">
			<form action="CpiDataListServlet" method="get">
				<table width="100%" align="center" cellspacing="0" cellpadding="0">
					<tr>
					<c:set target="${mypage}" property="where" value="datatype=${datatypeval}&datatypechild=${datatypechildval}&dataarea=${dataareaval}&cpidate=${cpidateval}" />
						${mypage.pageing }
					</tr>
				</table>
			</form>
		</div>
		</div>
		
	</div>
</body>
</html>
